// index.js
Page({
	takePhoto: function () {
		wx.chooseMedia({
			count: 1,
			sizeType: ['original'],
			sourceType: ['camera'],
			mediaType: ['image'],
			camera: ['back'],
			success: function (res) {
				const tempFilePaths = res.tempFiles[0].tempFilePath;
				wx.setStorageSync('takingPhoto', tempFiles[0].tempFilePath);	
				console.log(res.tempFiles[0].tempFilePath);
				// 图像处理
			},
			fail: function (error) {
				console.error(error);
				// 图像处理
			}
		});
	},
	chooseImage: function () {
		wx.chooseMedia({
			count: 1,
			sizeType: ['original'],
			sourceType: ['album'],
			mediaType: ['image'],
			success: function (res) {
				const tempFilePaths = res.tempFiles[0].tempFilePath;
				wx.setStorageSync('takingPhoto', tempFiles[0].tempFilePath);	
				console.log(tempFilePaths);
				// 图像处理
			},
			fail: function (error) {
				console.error(error);
				// 图像处理
			}
		});
	},
	navigateToUsing: function () {
		wx.navigateTo({
			url: '/pages/usingWarning/usingWarning',
			success: function (res) {
				console.log("成功跳转到使用须知页面");
			},
			fail: function (err) {
				console.error("跳转到处理使用须知失败", err);
			}
		});
	},
	navigateToKnowledge: function () {
		wx.navigateTo({
			url: '/pages/knowledge/knowledge',
			success: function (res) {
				console.log("成功跳转到菌种科普页面");
			},
			fail: function (err) {
				console.error("跳转到菌种科普失败", err);
			}
		});
	},
	navigateToHandling: function () {
		wx.navigateTo({
			url: '/pages/handling/handling',
			success: function (res) {
				console.log("成功跳转到处理记录页面");
			},
			fail: function (err) {
				console.error("跳转到处理记录页面失败", err);
			}
		});
	},
	navigateTosaving: function () {
		wx.navigateTo({
			url: '/pages/saving/saving',
			success: function (res) {
				console.log("成功跳转到保存的记录页面");
			},
			fail: function (err) {
				console.error("跳转到保存的记录页面失败", err);
			}
		});
	},
	open: function () {
		wx.login({
      success: function(res) {
       console.log(res);
        if (res.code) {
        } else {
          console.log('获取用户登录态失败！' + res.errMsg)
        }
      },
  fail: function(){
    console.log("启用wx.login函数，失败！");
  },
  complete:function(){
    console.log("已启用wx.login函数");
  }
});
	},
	onShow() {
		if (typeof this.getTabBar === 'function' && this.getTabBar()) {
			this.getTabBar().setData({
				selected: 0
			})
		}
	}
})